<%@page import="sdfi.lee.DAO.NewsDAO"%>
<%@page import="java.util.List"%>
<%@page import="sdfi.lee.Entity.News"%>
<%@page import="java.util.Date"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
    <%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
    <%@taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<link rel="stylesheet" href="../css/index.css" />
<link rel="stylesheet" href="../css/level.css" />
<script type="text/javascript" src="../js/jquery-1.6.js" ></script>
<script type="text/javascript" src="../js/index.js"></script>
<title>国家新药创制平台（山东）</title>
<meta content="<a href='<c:url value='/news/o_newslist.jsp?pg=1&type=${param.type}'/>'>
	<c:if test='${param.type==4}' >发展规划</c:if>
	<c:if test='${param.type==5}' >服务指南</c:if>
	<c:if test='${param.type==7}' >图片新闻</c:if></a>" name="location">
</head>
<body>
<%
	String pg=request.getParameter("pg");
	String type=request.getParameter("type");
List<News> list=new NewsDAO().getAllNew(Integer.valueOf(pg).intValue(),Integer.valueOf(type).intValue(),20);
request.setAttribute("list",list);
Date dt=new Date();
Date d3d=new Date(dt.getTime()-24*3*3600*1000);
request.setAttribute("d3d",d3d);
int count=0;
int intpg=Integer.valueOf(pg).intValue();
if("4".equals(type))
{
	//发展规划
	Object oj=session.getAttribute("fazhanguihua");
	if(oj==null) session.setAttribute("fazhanguihua",new NewsDAO().getNewsAccount(4));
	oj=session.getAttribute("fazhanguihua");
	count=((Integer)oj).intValue();
}else if("5".equals(type))
{
	//服务指南
	Object oj=session.getAttribute("fuwuzhinan");
	if(oj==null) session.setAttribute("fuwuzhinan",new NewsDAO().getNewsAccount(5));
	oj=session.getAttribute("fuwuzhinan");
	count=((Integer)oj).intValue();
}else 
{
	Object oj=session.getAttribute("tupianxinwen");
	if(oj==null) session.setAttribute("tupianxinwen",new NewsDAO().getNewsAccount(7));
	oj=session.getAttribute("tupianxinwen");
	count=((Integer)oj).intValue();
	
}
%>

            	<c:forEach var="news" items="${requestScope.list}">
            			<c:choose>
                    		<c:when test="${requestScope.d3d>news.newsdate }">
                    		  <div class="newsitem">
                    		</c:when>
                    		<c:otherwise>
                    		  <div class="newsitem_new">
                    		</c:otherwise>
                    	</c:choose>
            		
            <c:url value="/news/o_newsdetail.jsp?pg=${param.pg}&type=${param.type}&id=${news.id}" var="newsurl"></c:url>
            			
            			<div class="newstitle">
            				<a href="${newsurl}" title="${news.newstitle}">${news.newstitle}</a>
            			</div>
            			<div class="newsdate">
            				${news.newsdate }
            			</div>
            		</div>
            	 </c:forEach>
                <div id="pages">
                	
                	 <a href="<c:url value='/news/o_newslist.jsp?pg=1&type=${param.type }' />">首页
                     </a>
                     		  <c:choose>
                		<c:when test='${param.pg==null||param.pg==""||param.pg==1}'>
                			<font>上页</font>
                		</c:when>
                		<c:otherwise>
                			<c:url value='/news/o_newslist.jsp?pg=${param.pg-1}&type=${param.type }'  var="down"/>
                			 <a href="${down}">上页</a>
                		</c:otherwise>
                	</c:choose>
                     	<%
                     		request.setAttribute("all",count/20+1);
                     
                     		for(int i=1;i<=(count/20)+1;i++)
                     		{
                     			request.setAttribute("i",i);
                     			if((intpg>=i&&intpg-i<5)||(i-intpg<=5&&intpg<i))
                     			{   
                     				if(intpg!=i)
                     				{
                     	%>
                     				
                		<a href="<c:url value='/news/o_newslist.jsp?pg=${requestScope.i}&type=${param.type }' />">
                			<%=i%>
                		</a>
                			<%
                     				}else
                     				{
                			%>
                				<font><%=i%></font>
                			<%
                     				}
                     			}else{
                			%>
                			<a href="<c:url value='/news/o_newslist.jsp?pg=${requestScope.i}&type=${param.type }'/>" style="display:none">
                			<%=i%>
                		</a>
                     		<%	
                     			}
                     		}
                     		%>
                     		<c:choose>
                   		<c:when test="${fn:length(requestScope.list)<20}">
                   			<font>下页</font>
                   		</c:when>
                   		<c:otherwise>
                   		<a href="<c:url value='/news/o_newslist.jsp?pg=${param.pg+1}&type=${param.type }' />">下页</a>
                   		</c:otherwise>
                   	</c:choose>
                   	 <a href="<c:url value='/news/o_newslist.jsp?pg=${requestScope.all}&type=${param.type }' />">最后一页
                     </a>
                    
                </div>
                <div style="clear:left"></div>
            
</body>
</html>